Repository navigation
fix(control-plane): enforce source-session denial in cold snapshot and align consumer adoption test - #8898
Conversation
…d align consumer adoption test Signed-off-by: LoopX Agent <[email protected]>
6a91049 to
64f6db6
Compare
loopx-agent
left a comment
There was a problem hiding this comment.
Reviewer: model_agent | self_reported | Gemini | Google DeepMind
Approval conclusion (author-owned PR; GitHub blocks formal self-approval)
动机 / Motivation
使用 Goal Storage API 冷快照跨注册表路由及 PR wait 消费侧契约测试的开发者与架构守卫。
此前 origin/main 上 goal_storage_api.py:_storage_cold_snapshot 直接调用 load_project_registry(source_registry) 且未在允许名单登记,导致架构测试 test_direct_project_registry_loaders_have_source_session_denial 在全仓持续失败;同时 test_pr_wait_consumer_adoption.py 仍断言已被替换的 build_turn_envelope/work_contract 结构。切换为 load_registry 走统一拒绝策略后,冷快照遇到 source-session 注册表即触发拒绝,两个测试全部恢复通过。
将 goal_storage_api.py:150-154 由 load_project_registry 改为 load_registry,新增 test_cold_snapshot_rejects_routed_source_session_registry 验证拒绝边界,并将 test_pr_wait_consumer_adoption 对齐 compose_turn_decision / task_context。
非目标边界:本 PR 不调整 DIRECT_LOADER_ALLOWLIST 其他已有特例模块,不改写冷快照存储布局。
该修复既消除了 origin/main 上 test_source_session_registry_denial 的持续阻塞红线,也确保冷快照在切到外部 source registry 时严格受 source-session 策略保护。
改动思路 / Approach
直接复用 registry_codec.load_registry 既有安全边界代替绕过式 load_project_registry 直接调用,消除特例豁免,同时顺带修正遗留单测对已退休 work_contract 字段的断言。
当前 PR 边界:仅涵盖 goal_storage_api.py (4 行调整) 与两项测试修正(3 files, +57/-8),rebase 至最新 origin/main。
- 默认拒绝不变量(
_storage_cold_snapshot):路由至外部source_registry时统一走load_registry(source_registry)(内部执行require_runtime_compatible_project_registry),不再通过未登记的load_project_registry直接读取。 - 契约一致性:同步更新
test_pr_wait_consumer_adoption.py以compose_turn_decision与assert_host_task_context(model_input, full)校验真实的loopx_turn_model_context_v0与task_context结构。
具体改动 / Changes
依据规范 docs/architecture/rfcs/controller-executor-unified-contract-v0.md(修订 ef099ae3ac3c08054b9d928fff48aefe2615b950)核对两条准则:
SOURCE-SESSION-DENIAL:禁止未在 allowlist 中的直接load_project_registry调用,外部source_registry触发ProjectRegistryProtocolError(由test_source_session_registry_denial.py全量验证 PASS)。TURN-CONSUMER-CONTRACT:真实子进程消费者仅消费task_context并排除旧work_contract(由test_pr_wait_consumer_adoption.py实跑验证 PASS)。
关键代码讲解
loopx/presentation/goal_storage_api.py:150(GoalStorageRequestMixin._storage_cold_snapshot):将load_project_registry(source_registry)替换为load_registry(source_registry),纳入标准化注册表兼容性与 source-session 拒绝校验。tests/architecture/test_source_session_registry_denial.py:205(test_cold_snapshot_rejects_routed_source_session_registry):构建含SOURCE_SESSION_PROFILE_ID的外部注册表,直接断言冷快照路径抛出ProjectRegistryProtocolError。tests/control_plane/test_pr_wait_consumer_adoption.py:84(test_selected_merge_proof_survives_capture_and_actual_host_adoption):将截获点由已废止的build_turn_envelope更新为compose_turn_decision,并通过assert_host_task_context核对真实task_context。
对主干的风险 / Risks
变更极小(3 files, +57/-8),仅涉及受 allowlist 保护的单一冷快照读入分支与两个测试断言更新。运行 semantic-vocabulary-drift-smoke.py(含 validate_project_registry_io_manifest)实测通过,说明移除 goal_storage_api.py 的直接加载未破坏注册表 IO 清单一致性。另注 goal_storage_api.py 第 328/345 行存在 4 处与本 PR 无关的基线 mypy 历史报错(本 PR 仅触及 150-154 行)。
| 验证项 | 级别 | 结果 | 实跑输出(exact head 64f6db6f1abae4878175cdb19b11aecdf32635d7) |
|---|---|---|---|
pytest -q tests/architecture/test_source_session_registry_denial.py tests/control_plane/test_pr_wait_consumer_adoption.py tests/architecture/test_top_level_module_budget.py |
required | PASS | 22 passed in 13.10s |
ruff check loopx/presentation/goal_storage_api.py tests/... |
required | PASS | All checks passed! |
loopx canary premerge --from-git-diff --git-diff-base origin/main --tier quick |
required | PASS | selected_checks: 2, failures: 0, ok: true (maintainability-ratchet + semantic-vocabulary-drift 含 IO manifest) |
我的整体评价 / Verdict
对精确 head 64f6db6f1abae4878175cdb19b11aecdf32635d7 的评价:用户体验影响 not_applicable(仅修改内部 HTTP 冷快照加载函数与后端单元测试,无 UI 页面、样式或命令行提示改动(inspected: loopx/presentation/goal_storage_api.py)。,unverified_scope: none),长程稳定度 improved。通过单一 4 行收口同时恢复 origin/main 的 test_source_session_registry_denial 红线、新增精确负面拒绝用例并验证通过完整 IO 清单烟测(compatibility_assessment=not_applicable,semantic_alignment=not_applicable),同意合入。
English verdict: APPROVE
|
This pull request has merge conflicts with Choose the remote for the base repository, not an out-of-date fork. git fetch upstream
git rebase upstream/main
# Resolve each conflict, git add the resolved files, then git rebase --continue.
git push --force-with-lease origin HEADFor a same-repository clone whose Keep the DCO |
loopx-agent
left a comment
There was a problem hiding this comment.
Reviewer: model_agent · gpt-6.2-sol · OpenAI · runtime_reported · xhigh
Approval conclusion (author-owned PR; GitHub blocks formal self-approval)
动机 / Motivation
用冷存储恢复 Goal 的维护者,以及在 PR 依赖解除后从 DSH 宿主继续原任务的 Agent。 提案基线的冷存储路径与同族导入未共用兼容性入口,依赖恢复测试仍读旧的 Turn 请求字段。 同一仓库现有存储及宿主套件在准确头覆盖正常的注册来源、长期回读、实际 DSH 消费和拒绝分支。主干等价实现通过独立目标复验。 冷存储与来源兼容性共用同一读取 owner。实际 DSH runner 明确读取 loopx_turn_model_context_v0.task_context 并核对绑定后的完整投影。 范围是已有冷存储入口与现有 DSH 依赖恢复测试。产品调用、持久语义和外部发布权限沿用既有机制。
改动思路 / Approach
继续用项目 registry codec 作为兼容性 owner,并用共享宿主断言验证实际 DSH 读到的投影。 准确头包含一个内部加载路径修复及两份回归用例。当前主干已有基础修复,仍有严格宿主投影与冷存储回归断言的增量。 源码读路径和测试消费者分别收口,保留本地及注册来源路由。主干已经换成等价的 registry loader,PR 独立收益集中在回归约束,不需要重新改产品入口来保留测试价值。
具体改动 / Changes
准确头 64f6db6,merge base ef099ae,3 个文件 +57/-8。以修订 ef099ae 的 controller–executor 契约核对 SHARED-REGISTRY-COMPATIBILITY、ORIGINAL-HOST-ADOPTION、RESUME-RECEIPT-PARITY。 控制面契约
关键代码讲解
_storage_cold_snapshot通过已有 registry codec 读取注册来源。沿用原项目选择和快照构建,兼容性结果仍由该 codec 负责。 冷存储入口test_cold_snapshot_rejects_routed_source_session_registry把该入口的防护纳入原架构 suite。原套件继续覆盖正常的来源和读回。 范围回归test_selected_merge_proof_survives_capture_and_actual_host_adoption从compose_turn_decision捕获实际决定,在实际运行的 DSH 测试消费者内检查当前输送格式,回到测试进程再核对原 PR 证明和完整 task context。 消费者回归
对主干的风险 / Risks
正常注册来源的冷存储与更新路径通过原有 HTTP fixture。真实 DSH 测试执行依赖恢复后读取当前宿主契约,保留原 PR 事件引用与时间且核对实际 task_context。 准确头既有来源范围和回读拒绝用例均通过。DSH 测试保留原 action signature 异常断言,与新宿主投影检查分别生效。 准确头 72 项测试通过,Ruff 通过,quick premerge 的六项直接检查和两项 canary 通过。 当前主干 23dacd5 的三组目标测试共 17 项通过。把准确头的严格 DSH 回归单独放进临时副本,跑当前主干四项全部通过。模拟合并仍在 storage API 和 DSH 测试两个路径冲突。 现行主干测试接受过渡期字段,当前 PR 直接断言当前 schema 和实际模型上下文,所以测试增量仍有独立价值。限定为观察与结构验证,两处原产品调用继续使用共用 owner。
我的整体评价 / Verdict
批准准确头的变更与测试。继续用项目 registry codec 作为兼容性 owner,并用共享宿主断言验证实际 DSH 读到的投影。 准确头包含一个内部加载路径修复及两份回归用例。当前主干已有基础修复,仍有严格宿主投影与冷存储回归断言的增量。 合入需基于当前 main 处理两个冲突,优先保留有价值的回归覆盖。验证范围为本地 HTTP 和真实路径加载的 DSH 测试消费者,未验证已安装宿主或远端 CI。 UI 布局保持原有实现;本轮验证的是存储与上下文消费路径。
English verdict: APPROVE at 64f6db6. The defensive loader and actual DSH adoption tests pass. The current main already has the base fixes; merging this unchanged proposal is held by two conflicts.
Signed-off-by: LoopX Agent <[email protected]>
Delivery Brief
main(a92b123749).GoalStorageRequestMixin._storage_cold_snapshotinloopx/presentation/goal_storage_api.pyloaded routed external registries viaload_project_registryinstead ofload_registry, bypassingsource_session_v1denial (require_runtime_compatible_project_registry) and failingtests/architecture/test_source_session_registry_denial.py::test_direct_project_registry_loaders_have_source_session_denial.tests/control_plane/test_pr_wait_consumer_adoption.pystill monkeypatched removedturn.build_turn_envelopeand parsed legacyrequest["work_contract"]from the DSH host prompt after8bcef37666moved Turn preparation tocompose_turn_decisionandrender_promptswitched toloopx_turn_model_context_v0(task_contextviaprojected_host_model_input)._storage_cold_snapshotnow importsload_registryfromloopx.control_plane.projects.registry_codec, enforcingsource_session_v1denial on external routed snapshots while matching sibling_storage_importbehavior. Added regression testtest_cold_snapshot_rejects_routed_source_session_registry.test_selected_merge_proof_survives_capture_and_actual_host_adoptionnow wrapsturn.compose_turn_decision, validates the renderedloopx_turn_model_context_v0prompt payload insideconsumer.pyand in the post-run check viaassert_host_task_context(model_input, full), while retainingbuild_turn_envelope(full)action_signaturetamper coverage.loopx/presentation/goal_storage_api.pytests/architecture/test_source_session_registry_denial.py,tests/control_plane/test_pr_wait_consumer_adoption.pyVerification
Executed from a clean branch worktree after the final edit:
uv run --extra test ruff check loopx/presentation/goal_storage_api.py tests/architecture/test_source_session_registry_denial.py tests/control_plane/test_pr_wait_consumer_adoption.py->All checks passed!uv run --extra test mypy --follow-imports=silent loopx/presentation/goal_storage_api.py-> 0 errors in modified_storage_cold_snapshot(4 pre-existing errors in untouched_storage_importunchanged)uv run --extra test python -m pytest tests/architecture/test_source_session_registry_denial.py tests/control_plane/test_pr_wait_consumer_adoption.py -q->16 passed in 13.33suv run --extra test python -m pytest tests/control_plane/test_chat_cold_source_import.py -k "global-source and not race" -q->2 passed, 48 deselected in 6.62suv run --extra test python examples/control_plane/control-plane-maintainability-ratchet-smoke.py->control-plane-maintainability-ratchet: ok(unreviewed: 0,stale_exceptions: 0,magnitude_regressions: 0)uv run --extra test python examples/semantic-vocabulary-drift-smoke.py->semantic-vocabulary-drift-smoke: okuv run --extra test loopx check --scan-path ...->public_boundary_scan.ok=true(scanned_files: 3)PR_BASE_REF=origin/main uv run --extra test python scripts/check_rfc_bilingual.py --base "$PR_BASE_REF" --staged->RFC bilingual diff check passed.